<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$proid = $_POST['pro_id'];

global $wp_query, $woocommerce;
$option = get_option('kkfashion_1_settings');
$args = array('post_type' => 'product', 'p' => $proid);
query_posts($args);
while (have_posts()) : the_post();
    $post_id = get_the_ID();
    $get_regular_price = get_post_meta($post_id, '_price', true);
    $get_regular_price = $get_regular_price ? $get_regular_price : 0;

    $get_sku = get_post_meta($post_id, '_sku', true);
    //$tags = get_the_term_list($post_id, 'product_tag', '', ', ', '');
    $product_cats = wp_get_post_terms( $proid, 'product_cat' );
     switch ($product_cats[0]->name) {
            case 'Đầm công sở':
                $type_tags = 'dcs_tags';
                break;
            case 'Đầm dạ hội':
                $type_tags = 'ddh_tags';
                break;
            case 'Phụ kiện':
                $type_tags = 'pk_tags';
                break;
            case 'Váy chống nắng':
                $type_tags = 'vcn_tags';
                break;
            default:
                $type_tags = 'footer_tags';
                break;
        }
        $tags = '';
        foreach(explode(",", $option[$type_tags]) as $tag ){
            $tagurl = get_site_url().'/product-tag/'.str_replace(' ','-',trim(vn_str_filter($tag)));
            $tags .= "<a href='$tagurl'>$tag</a>, "; 
        }
    ?>
    <div class=" col-lg-3 col-sm-3 col-12  m10 hidden-sm">
        <h2 class="contact-name"><?php echo get_the_title() . ' ' . $get_sku ?></h2>
        <div class="note"><?php echo get_the_content() ?></div>
        <p>Tags: <?php echo $tags; ?></p>
        <p id="prosize">
            <span class="size active" itemid="s" >S</span>
            <span class="size" itemid="m" >M</span>
            <span class="size" itemid="l" >L</span>
            <span class="size xl" itemid="xl" >XL</span>
        </p>
        <?php if ($get_regular_price) { ?>
            <p class="price">
                <span class="pull-left price-right"><?php echo number_format($get_regular_price, 0, ',', '.'); ?> VNĐ</span>
                <span class="pull-right hidden-md"><?php echo $get_sku; ?></span>
            </p>
            <div>

                <div class="col-lg-5 col-sm-12 product-cart no-right">
                    <a href="<?php echo site_url() ?>/cart">Giỏ hàng (<span id="numpro"><?php echo $woocommerce->cart->cart_contents_count; ?></span>)</a>
                </div>
                <div class="col-lg-7 no-right ycart">
                    <?php do_action('woocommerce_single_product_summary') ?>
                </div>

            </div> 
        <?php } else { ?>
            <div class="outofpro">HẾT HÀNG</div>
        <?php } ?>
        <div class="clearfix"></div>
        <div class="hidden-sm" style="margin-top: 10px;">
            <div class="col-lg-6 no-left no-right">Gửi mail cho bạn</div> 
            <!-- AddThis Button BEGIN -->
            <div class="addthis_toolbox addthis_default_style " style="display: inline-block;width: 95px;">
            <a class="addthis_button_preferred_1"></a>
            <a class="addthis_button_preferred_2"></a>
            <a class="addthis_button_compact"></a>
            <a class="addthis_counter addthis_bubble_style"></a>
            </div>
            <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=xa-526f7c6c2c7fadaa"></script>
        </div>
            <!-- AddThis Button END -->
        <div class="descpro"><?php do_action('woocommerce_single_product_excerpt') ?></div>

        <div class="clearfix"></div>
    </div>

    <div class="col-lg-5 col-sm-5 col-12 m10 hidden-sm">
        <div class="thumb-product m10">
            <a href="<?php the_permalink() ?>">
                <img src="<?php echo get_mthumb_link($get_sku, '356_520'); ?>" class="img-thumbnail" />

            </a>
        </div>
        <div class="col-lg-9 col-sm-9 no-left"><h4><?php echo get_the_title() . ' ' . $get_sku ?></h4></div>
        <div class="col-lg-3 col-sm-3 no-left">
            <div class="btn btn-custom"><a href="<?php the_permalink() ?>">Chi tiết</a></div>
        </div>
    </div>
<?php endwhile; ?>